using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Utility;
using DTO;

namespace BUS
{
    public  class tbloaigiaodichBUS
    {
        public static tbloaigiaodichcollection Get(string where,
           int pageindex,
           int pagesize,
           string orderby,
           string orderdirection,
           out int total)
        {
            tbloaigiaodichDAL loaigiaodichDAL = new tbloaigiaodichDAL();
            return loaigiaodichDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbloaigiaodichcollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbloaigiaodichDAL loaigiaodichDAL = new tbloaigiaodichDAL();
            return loaigiaodichDAL.Get(cri.Criter, 0, 0, loaigiaodichcolumns.maloaigiaodich .ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbloaigiaodich  GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, loaigiaodichcolumns.maloaigiaodich .ToString(), Condition.EQUAL, iD);
            tbloaigiaodichDAL loaigiaodichDAL = new tbloaigiaodichDAL();
            tbloaigiaodichcollection loaigiaodichcollection = loaigiaodichDAL.Get(cri.Criter,
                     0, 0, loaigiaodichcolumns.maloaigiaodich.ToString(), OrderDirection.ASC.ToString(), out total);
            if (loaigiaodichcollection .Count > 0)
                return loaigiaodichcollection [0];
            return null;
        }
    }
}
